//
//  XFDCommitSuccessController.m
//  XFDLogin_Example
//
//  Created by 韩冰 on 2017/11/6.
//  Copyright © 2017年 GL-ZHU. All rights reserved.
//

#import "XFDCommitSuccessController.h"
#import <XFDCommon/UIColor+Extension.h>
#import <XFDCommon/UIImage+Extension.h>
#import <XFDCommon/NSString+HBExtension.h>
#import <Masonry/Masonry.h>
#import <BlocksKit/UIControl+BlocksKit.h>
#import <XFDCommon/HBCommon.h>

@interface XFDCommitSuccessController ()

@property (nonatomic, strong)UIImageView *imageView;
@property (nonatomic, strong)UILabel *titleLabel;
@property (nonatomic, strong)UILabel *detailLabel;
@property (nonatomic, strong)UIButton *button;


@end

@implementation XFDCommitSuccessController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:self.imageView];
    [self.view addSubview:self.titleLabel];
    [self.view addSubview:self.detailLabel];
    [self.view addSubview:self.button];
    [self.imageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.view.mas_top).with.offset(100);
        make.centerX.equalTo(self.view.mas_centerX);
        make.width.mas_offset(80);
        make.height.mas_offset(80);
    }];
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.imageView.mas_bottom).with.offset(20);
        make.centerX.equalTo(self.view.mas_centerX);
        make.width.mas_offset(200);
        make.height.mas_offset(25);
    }];
    [self.detailLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.titleLabel.mas_bottom).with.offset(20);
        make.centerX.equalTo(self.view.mas_centerX);
        make.width.equalTo(self.view.mas_width);
        make.height.mas_offset(60);
    }];
    [self.button mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.detailLabel.mas_bottom).with.offset(50);
        make.right.equalTo(self.view.mas_right).with.offset(-40);
        make.left.equalTo(self.view.mas_left).with.offset(40);
        make.height.mas_offset(40);
    }];
}

-(UIImageView *)imageView{
    if (!_imageView) {
        _imageView = [[UIImageView alloc]init];
        _imageView.image = [UIImage hb_imagePathWithName:@"register_submit" bundle:@"XFDLogin" targetClass:[self class]];
    }
    return _imageView;
}

- (void)dealloc{
    
}
- (UILabel *)titleLabel{
    if (!_titleLabel) {
        _titleLabel = [[UILabel alloc]init];
        _titleLabel.text = @"提交成功";
        _titleLabel.textAlignment = NSTextAlignmentCenter;
        _titleLabel.font = [UIFont boldSystemFontOfSize:24];
        _titleLabel.textColor = [UIColor HB_ColorWithHexString:@"#333333"];
    }
    return _titleLabel;
}
- (UILabel *)detailLabel{
    if (!_detailLabel) {
        _detailLabel = [[UILabel alloc]init];
        NSMutableAttributedString *str = [[NSMutableAttributedString alloc]initWithString:@"请等到管理员审核\n审核结果将以短信方式进行通知"];
        [str setAttributes:@{
                             NSFontAttributeName :[UIFont systemFontOfSize:14],
                             NSForegroundColorAttributeName :[UIColor HB_ColorWithHexString:@"#f97205"]
                             
                             } range:NSMakeRange(0, str.length)];
        [_detailLabel setAttributedText:[str stringWithParagraph]];
        _detailLabel.numberOfLines = 2;
        _detailLabel.textAlignment = NSTextAlignmentCenter;
    }
    return _detailLabel;
}

- (UIButton *)button{
    if (!_button) {
        _button = [UIButton buttonWithType:UIButtonTypeCustom];
        _button .backgroundColor = [UIColor HB_ColorWithHexString:@"#3eabf9"];
        [_button setTitle:@"知道了" forState:UIControlStateNormal];
        [_button setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        _button.titleLabel.font = [UIFont systemFontOfSize:14];
        WEAKSELF
        [_button bk_addEventHandler:^(id sender) {
            STRONGSELF
            [strongSelf.navigationController popToRootViewControllerAnimated:YES];
        } forControlEvents:UIControlEventTouchUpInside];
        _button.layer.cornerRadius = 5.0;
        _button.layer.masksToBounds = YES;
    }
    return _button;
}

@end
